import { downloadimage } from './cache.js';
import fs from 'fs';
import path from 'path';

function ESDE(filePath) {
    const dirname = path.dirname(filePath);  
    if (fs.existsSync(dirname)) {  
      return true; 
    }
    fs.mkdirSync(dirname, { recursive: true }); 
  }

async function HID(id, url, localPath) {
    const filePath = `${localPath}/${id}.png`;
    if (!fs.existsSync(filePath)) {
      ESDE(filePath);  
      await downloadimage(url, filePath);  
    }
    return filePath; 
  }

  export { HID };